<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<base target="sysfram" />
<title>${fns:getConfig('productName')}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Bootstrap -->
<link href="./static/bootstrap-3.3.0/css/bootstrap.min.css"
	rel="stylesheet">
<!-- styles -->
<link href="./static/myCss/css/styles.css" rel="stylesheet">
<link href="./static/myCss/css/index.css" rel="stylesheet"> 
<script src="./static/js/jquery-3.1.1.min.js"></script>
<!-- <script src="./static/myCss/js/index.js"></script> -->
<script src="./static/bootstrap-3.3.0/js/bootstrap.min.js"></script>
<script src="./static/zongdao/zongdao-1.0.js"></script>
<script type="text/javascript">
		/*验证token是否过期*/
		var token = ZD.ux.GetCookie(ZD.base.TOKEN);
		if (token == null) {
			//判断是否用户已经登陆过
			window.location.href = "login.jsp";
		}
		
		$(function() {
			/**设置高度**/
				funcOnresize();	
		});
		/**设置高度**/
		function funcOnresize() {
			var h = document.documentElement.clientHeight;
			console.log('自适应高度'+h);
			$("#main-content").height(h - 100);
		}
		/*退出登录*/
		function LogOut(){
			ZD.ux.Ajax({
				data:{method:'finance.sys.user.logOut'},
				async:false,
				success:function(res){
					if(res.status == 0){
						window.location.href = "login.jsp";
					}else{
						ZD.msg.alert("意外错误.");
					}
				}
				
			});
		}
		
		
	</script>
</head>
<body>
	<div class="header">
		<div class="container">
			<div class="row">
				<div class="col-md-5">
					<!-- Logo -->
					<div class="logo">
						<h1>
							<a>财务系统</a>
						</h1>
					</div>
				</div>
				<div class="col-md-5">
					<div class="row">
						<div class="col-lg-12"></div>
					</div>
				</div>
				<div class="col-md-2">
					<div class="navbar navbar-inverse" role="banner">
						<nav
							class="collapse navbar-collapse bs-navbar-collapse navbar-right"
							role="navigation">
						<ul class="nav navbar-nav">
							<li class="dropdown"><a href="#" class="dropdown-toggle"
								data-toggle="dropdown">用户信息 <b class="caret"></b></a>
								<ul class="dropdown-menu animated fadeInUp">
									<li><a onclick="javascript:LogOut();">退出登录</a></li>
								</ul></li>
						</ul>
						</nav>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="page-content">		
	<div class="row">
		<div id="menu" class="col-md-2">
				 <div class="sidebar content-box">
					<ul class="nav" id="MainMenu">
					
					</ul>
				</div> 
		
		</div>			

		<div id="content" class="col-md-10">
				<div id="main-content" class="clearfix">
					<iframe id="sysfram" name="sysfram" src="./views/user.jsp"
						style="width: 99%;min-height:100%;margin-right:5px;" scrolling="auto"
						frameborder="0">
						</iframe>
				</div>
			</div>
		</div>
	</div>

<script type="text/javascript">
/*获取用户菜单列表信息*/
getUserMenu();	
/*获取用户菜单列表信息*/
function getUserMenu(){
	ZD.ux.Ajax({
		data:{method:'finance.sys.user.getUserMenu'},
		async:false,
		success:function(result){
			if(result.status == '1'){
				window.location.href = "login.jsp";
			}
			var data = result.data;
			console.log(data);
			var html="";
			var son ="";
			var sum="";
			//var pull="<span class='caret pull-right'></span>";
			for(i in data){
				if(data[i].menu_grade==1){
					html="<a href='javascript:void(0);' class='data_url' "+
					" data-key='"+data[i].menu_url+"' data-id='"+data[i].id+"'>"
					+"<i class='glyphicon glyphicon-calendar'></i>"+data[i].menu_name+"";
					
		
					for(j in data){
						if(data[j].menu_father==data[i].id &&  data[j].menu_grade==2){
							son=son+"<li><a href='javascript:void(0);' class='data_url'"+
							" data-key='"+data[j].menu_url+"' data-id='"+data[j].id+"'>"+data[j].menu_name+"</a></li>";
						}
					}
					if(son!=""){
						son="<ul>"+son+"</ul>";
						sum=sum+"<li class='submenu'>"+html
						+"<span class='caret pull-right'></span></a>"
						+son+"</li>"
					}else{
						sum=sum+"<li>"+html+"</a>"+"</li>"
					}
					son="";
				}
			}
			console.log(sum);
			$('#MainMenu').html(sum);
			
			 $('.data_url').click(function(){
				var value = '<%=session.getAttribute("SESSION_USER")%>';
				if(value == null){
					 window.location.href = "login.jsp";
					return ;
				 }
				console.log($(this).text());
				$(this).parents().find('li').removeClass("current");
				$(this).parent().attr("class", "current");
				$(this).attr("class", "current");
				var furl = $(this).attr("data-key");
				console.log(furl);
				ZD.ux.OpenMenuUrl("<%=basePath%>", furl);
				});
			
		},
		error:function(error){
			window.location.href = "login.jsp";
		}
	});
}
$(".submenu > a").click(function(e) {
    e.preventDefault();
    var $li = $(this).parent("li");
    var $ul = $(this).next("ul");

    if($li.hasClass("open")) {
      $ul.slideUp(350);
      $li.removeClass("open");
    } else {
      $(".nav > li > ul").slideUp(350);
      $(".nav > li").removeClass("open");
      $ul.slideDown(350);
      $li.addClass("open");
    }
  });
</script>

</body>

</html>